<?php
namespace app\common\model;
use think\Db;
use think\Model;
/**
 * 工单问题
 * @author lcx
 * @date 2018-08-27
 */
class WorkOrderProblemModel extends Model{
    // 表名
    protected $name = 'work_order_problem';

    // 列表查询
    public function getAll($where, $field='*',$join=array(), $page=1, $pageSize=-1, $order='sort ASC') {
        $result = Db::name($this->name)
                ->where($where)
                ->join($join)
                ->field($field)
                ->page($page, $pageSize)
                ->order($order)
                ->select();
//        echo Db::name($this->name)->getLastSql();die();
        return $result;
    }

    // 数量查询
    public function getCount($where, $join) {
        $result = Db::name($this->name)
                ->where($where)
                ->join($join)
                ->count();
        return $result;
    }

    // 单个查询
    public function getOne($where=array(), $field='*',$join=array()) {
        $result = $this->where($where)
                ->join($join)
                ->field($field)
                ->find();
        return $result;
    }

    // 添加操作
    public function add($data)
    {
        $result = $this->insertGetId($data);
        return $result;
    }

    // 编辑操作
    public function edit($where, $data)
    {
        $result = $this->where($where)->update($data);
        return $result;
    }

}
